package com.itheima.web.controller.cms;


import com.itheima.service.cms.ICmsSubjectService;
import com.itheima.utils.MyPage;
import com.itheima.utils.PageResult;
import com.itheima.utils.ResultData;
import com.itheima.vo.cms.CmsSubject;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 专题表 前端控制器
 * </p>
 *
 * @author 王志斌
 * @since 2022-07-06
 */
@RestController
@RequestMapping("/subject")
public class CmsSubjectController {
    @DubboReference
    private ICmsSubjectService cmsSubjectService;
    /**
     * 获取全部商品专题
     * 接口地址:/subject/listAll
     * @return
     */
    @GetMapping("/listAll")
    private ResultData listAll(){
        List<CmsSubject> cmsSubjects = cmsSubjectService.listAll();
        return ResultData.ok("操作成功!",cmsSubjects);
    }
    /**
     * 根据专题名称分页获取商品专题(分页查询)
     * 接口地址:/subject/list
     * @return
     */
    @GetMapping("/list")
    public ResultData listByPage(@RequestParam(defaultValue = "1") Long pageNum,
                                            @RequestParam(defaultValue = "10") Long pageSize,
                                            String keyword){
        MyPage<CmsSubject> myPage=  cmsSubjectService.listpage(pageNum,pageSize,keyword);
        return ResultData.ok("操作成功",myPage);
    }

}
